﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="xbrl_aruande_bilansi_sisu", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(XbrlAruandeBilansiSisu))]
    public class XbrlAruandeBilansiSisuSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IXbrlAruandeBilansiSisu clazz;
        
        public XbrlAruandeBilansiSisuSerializer(IXbrlAruandeBilansiSisu clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("maketi_id");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.MaketiId))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("naitaja_id");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.NaitajaId))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("bil_veerg");
            if (clazz.BilVeerg!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.BilVeerg))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : BilVeerg");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("vaartus");
            if (clazz.Vaartus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Vaartus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Vaartus");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="maketi_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrl_aruande_bilansi_sisu>maketi_id");
                }
                clazz.MaketiId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("maketi_id")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrl_aruande_bilansi_sisu>maketi_id", Reader.LocalName);
            }
            if (Reader.LocalName=="naitaja_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrl_aruande_bilansi_sisu>naitaja_id");
                }
                clazz.NaitajaId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("naitaja_id")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrl_aruande_bilansi_sisu>naitaja_id", Reader.LocalName);
            }
            if (Reader.LocalName=="bil_veerg") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrl_aruande_bilansi_sisu>bil_veerg");
                }
                clazz.BilVeerg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("bil_veerg")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrl_aruande_bilansi_sisu>bil_veerg", Reader.LocalName);
            }
            if (Reader.LocalName=="vaartus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrl_aruande_bilansi_sisu>vaartus");
                }
                clazz.Vaartus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("vaartus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrl_aruande_bilansi_sisu>vaartus", Reader.LocalName);
            }
        }
    }
}
